﻿using Janus.BaseEntitys;
using Janus.Cores.Linq;
using Janus.Mes.POCO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Tests.Janus.Mes.SqlDal.ConsWrite.dal
{
    public class ResolveExpressionTest
    {
        public ResolveExpressionTest()
        {
            this.ResolveToSqlTest();
        }
        public void ResolveToSqlTest()
        {
            var searchParma = new SearchEntity<SysConfig>() { Model=new SysConfig()};
            searchParma.Model.Title = "t2";
            var e = System.Linq.Dynamic.DynamicExpression.ParseLambda<SysConfig, bool>("Title.Contains(@0)", searchParma.Model.Title);

            Indicator model = new Indicator();
            model.IndicatorName = "test";
            model.CreateDt = DateTime.Now;
            string expressWhere = "IndicatorName.Contains(@0) and CreateDt>=@1";
            Querier querier = new Querier();
            querier.Where("IndicatorName.Contains({@0})", model.IndicatorName);
            querier.Where("CreateDt>{@0}", model.CreateDt);
            List<object> p = null;
            expressWhere = querier.CombineWhere(out p);
            ResolveExpression reExpress = new ResolveExpression();
            reExpress.ResolveToSql<Indicator, bool>(expressWhere, p.ToArray());
            var where = reExpress.SqlWhere;
            var where2 = reExpress.Where;
        }
    }
}
